function initCharts4 (data){
    $.ajax({
        type: "POST",
        // url: "/bankingRegulatory/businessEstate",
        url: "/assets/main/estatebanking_2.json",
        data:{city:410100},
        success: function (msg){
            var myChart = echarts.init($('#prodNumber_2').get(0));
            var allData = msg.result,
                quantity1 = [],
                startDate = [];
            allData.forEach(function(data,index){
                quantity1[index] = data.count;
                startDate[index] = (data.distrcit_name);
            });

            option = {
                title: {
                    show: 'true',
                    text: '商品住房押品分布',
                    textStyle: {
                        color: '#ADADAD',
                        fontSize : 12
                    },
                    x: 'center'
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: '#999'
                        }
                    },
                    // formatter:'{b0}<br/>一手现房：{c0}</br> 一手期房：{c1}</br> 二手现房：{c2} </br>'
                    formatter: function(params) {
                        var res = '<div>';
                        res += '<strong>' + params[0].name + '</strong>'
                        for (var i = 0, l = params.length; i < l; i++) {
                            res += '<br/>' + params[i].seriesName + ' : ' + params[i].value + ' 个'
                        }
                        res += '</div>';
                        return res;
                    }
                },
                legend: {
                    // selectedMode:false,
                    orient: 'vertical',
                    bottom:'bottom',
                    data:['商品用房'],
                    textStyle: {
                        color : "#ADADAD"
                    },
                },
                xAxis: [
                    {
                        type: 'category',
                        axisLabel: {
                            interval: 0,
                            rotate: 0
                        },
                        data: startDate,
                        axisLine:{
                            lineStyle:{
                                color:'#ADADAD',
                            }
                        },
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        // name: '抵押率百分比',
                        axisLabel: {
                            formatter: '{value}'
                        },
                        axisLine:{
                            lineStyle:{
                                color:'#ADADAD',
                            }
                        },
                    }
                ],
                series: [
                    {
                        name:'商品用房',
                        type:'bar',
                        data:quantity1
                    }
                ]
            };
            if(startDate.length>10){
                option.xAxis[0].axisLabel.rotate = 30
            }

            myChart.setOption(option);
            window.onresize = function () {
                myChart.resize()
            };
        }
    })};
initCharts4();
$('#searchData').click(function(){
    var inputData = [],
        citys = $('#city').val(),
        districts = $('#district').val(),
        loansBalanceStarts = $('#loansBalanceStart').val(),
        loansBalanceEnds =  $('#loansBalanceEnd').val(),
        loansAmountStarts = $('#loansAmountStart').val(),
        loansAmountEnds = $('#loansAmountEnd').val(),
        startDateStarts = $('#startDateStart').val(),
        startDateEnds = $('#startDateEnd').val(),
        loansDurations = $('#loansDuration').val(),
        remainTimes = $('#remainTime').val(),
        risk = $('#risk').val(),
        buildAreaEnds = $('#buildAreaEnd').val(),
        buildAreaStarts = $('#buildAreaStart').val(),
        endDateStarts = $('#endDateStart').val(),
        endDateEnds = $('#endDateEnd').val(),
        inputData = {
            city:citys,
            district:districts,
            loansBalanceStart:loansBalanceStarts,
            loansBalanceEnd:loansBalanceEnds,
            loansAmountStart:loansAmountStarts,
            loansAmountEnd:loansAmountEnds,
            startDateStart:startDateStarts,
            startDateEnd:startDateEnds,
            loansDuration:loansDurations,
            remainTime:remainTimes,
            risk:risk,
            buildAreaEnd:buildAreaEnds,
            buildAreaStart:buildAreaStarts,
            endDateStart:endDateStarts,
            endDateEnd:endDateEnds
        };

    initCharts4(inputData)
});
